package customer

import (
	"context"
	"github.com/google/wire"
	"net/http"
	"sieve_admin_server_userpass/app/api/util"
	"sieve_admin_server_userpass/app/server"
	serviceCustomer "sieve_admin_server_userpass/app/service/customer"
)

var (
	_           util.API = (*UserAuthAPI)(nil)
	UserAuthSet          = wire.NewSet(wire.Struct(new(UserAuthAPI), "*"))
)

type UserAuthAPI struct {
	util.EmptyAPI
	UserAuthSrv *serviceCustomer.UserAuthSrv
}

func (a *UserAuthAPI) Cron() {

	_ = a.UserAuthSrv.Cron()
}

// 用户登录
func (a *UserAuthAPI) Login(ctx context.Context, c *server.Context, item map[string]interface{}) interface{} {

	return a.UserAuthSrv.Login(ctx, c, item)
}

func (a *UserAuthAPI) Logout(ctx context.Context, c *server.Context, uid uint64) interface{} {

	return a.UserAuthSrv.Logout(ctx, c, uid)
}

func (a *UserAuthAPI) GetUserLoginState(uid uint64) string {

	return a.UserAuthSrv.GetUserLoginState(uid)
}

func (a *UserAuthAPI) GetUserUid(r *http.Request) int {

	return a.UserAuthSrv.GetLoginUid(r)
}
